package com.aos.erp.manager.rest;

import com.aos.erp.common.bean.ResultEntity;
import com.aos.erp.manager.remote.DriverSchoolService;
import com.aos.erp.manager.remote.model.DriverSchool;
import com.aos.erp.manager.remote.model.Region;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

@Slf4j
@Api(tags = {"UI接口：公共接口"})
@RestController
@RequestMapping("/api/common")
public class RestCommonController {
    @Resource
    private DriverSchoolService driverSchoolService;

    @ApiOperation(value = "根据城市获取驾校列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "城市列表：city1,city2", dataType = "String", paramType = "Query")
    })
    @GetMapping("/queryDriverSchool")
    public ResultEntity<List<DriverSchool>> listDs(String ids) {
        return ResultEntity.success(driverSchoolService.querySchoolByCityId(Arrays.asList(ids.split(","))));
    }

    @ApiOperation(value = "获取城市列表")
    @GetMapping("/queryCityList")
    public ResultEntity<List<Region>> listNotice() {
        return ResultEntity.success(driverSchoolService.queryCityList(""));
    }
}
